<?php
/* @var $this yii\web\View */
use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap\ActiveForm;
$this->title = '当前项目--'.$projectName;
$this->params['breadcrumbs'][] = $this->title;

$get = Yii::$app->request->get();
$id=$get['id'];$apiId=$get['apiId'];
?>
<?php include('_searchApi.php');?>
<div class="col-xs-9">
    <div class="col-xs-12 padding-5 margin-top-10" style="background-color: #d9edf7;border-color:#bce8f1;color:#31708f;padding-top:15px;padding-bottom:15px">
        <div class="col-xs-7 pull-left">
            <div class="col-xs-12">
                <h4>
                    <span class="pull-left"><b class="cl-red"><?=$model->apiName?></b>-------编号: <span class="cl-red"><?=$model->number?></span></span>
                    <span><a href= "<?= Url::to([ 'api/add-api', 'apiId'=>$model->apiId,'id'=>$id]); ?>" class="pull-left btn btn-success" style="padding:2px 5px !important;margin-left:30px">编辑</a ></span>
                    <span><button class="pull-left btn btn-danger" onclick="delApi(<?=$id?>,<?=$model->apiId?>)" style="padding:2px 5px !important;margin-left:30px">删除</button></span>
					<span><button class="pull-left btn btn-warning" onclick="copyApi(<?=$apiId?>)" style="padding:2px 5px !important;margin-left:30px">复制</button></span>
<script language="javascript">
function copyApi(){
    var askName = layer.prompt({
		title: '输入新的api名称',
		formType: 0 //prompt风格，支持0-2
    }, function(pass){
	    location.href = "<?= Url::to([ 'api/copy', 'apiId'=>$model->apiId]); ?>&name="+pass;
        
    });
}
</script>
                </h4> 
            </div>
            <div class="col-xs-12 margin-top-10">
                <span style="padding:2px;" class="cl-red"><b><?=$model->type?></b></span>--
                <span style="padding:2px;" class="cl-red" id="url"><?=$model->apiUrl?></span>
            </div>
            <div class="col-xs-12 margin-top-10" ><b>描述</b>：<?=$model->apiDiscribe?></div>
        </div>
        <div class="col-xs-5 pull-right">
            <div class="col-xs-12 pull-left" >最后修改者: <?=Yii::$app->user->identity->username?> -- <?=$model->lastTime?></div>
            <div class="col-xs-12 pull-right native" id="readLogs"><span class="glyphicon glyphicon-plus"></span>&nbsp;查看logs</div>
            <div class="col-xs-12 pull-left" >
               <div id="logsData" style="display:none;position:absolute;z-index:99;left:10px;top:5px;background:#5cb85c;color:white;padding:2px">
                <?php
                    foreach ($logsData as $key => $value) {
                        echo '<div>'.$value->editTime.'--'.$value->content.'</div>';
                    }
                ?>
                </div>
            </div>
        </div>
    </div>

    <div class="col-xs-12 padding-5" style="margin:50px 0 0 0;background-color: #d9edf7;border-color:#bce8f1;color:#31708f">
        <div class="col-xs-12"><h4>请求参数</h4></div>
        <div class="col-xs-12">
            <table class="table">
              <thead>
                <tr><th>参数名</th><th>参数类型</th><th>必传</th><th>缺省值</th><th>描述</th></tr>
              </thead>
              <tbody>
                <?php
                    $params0=unserialize($model->params);
                    $pnum0 = count($params0['name']);
                    for( $i=0; $i<$pnum0; $i++ ) {
                ?>
                <tr>
                    <td><?=$params0['name'][$i]?></td>
                    <td><?=$params0['paramType'][$i]?></td>
                    <td><?=$params0['type'][$i]?></td>
                    <td><?=$params0['default'][$i]?></td>
                    <td><?=$params0['des'][$i]?></td>
                </tr>
                <?php
                    }
                ?>
              </tbody>    
            </table>
        </div>
    </div>

    <div class="col-xs-12 padding-5" style="margin:50px 0 0 0;background-color: #d9edf7;border-color:#bce8f1;color:#31708f">
        <div class="col-xs-12"><h4>返回参数</h4></div>
        <div class="col-xs-12" style="color:#3170AE">
        </div>
        <div class="col-xs-12">
            <table class="table">
              <thead>
                <tr><th>参数名</th><th>参数类型</th><th>缺省值</th><th>描述</th></tr>
              </thead>
              <tbody>
                 <?php
                    $params=unserialize($model->returnParams);
                    $pnum = count($params['name']);
                    for( $i=0; $i<$pnum; $i++ ) {
                        if($params['parent'][$i]=="1"){
                ?>
                        <tr>
                            <td><?=$params['name'][$i]?></td>
                            <td><?=$params['paramType'][$i]?></td>
                            <td><?=$params['default'][$i]?></td>
                            <td><?=$params['des'][$i]?></td>
                        </tr>
                <?php
                        }else{
                ?>
                        <tr style="text-align: center">
                            <td><?=$params['name'][$i]?></td>
                            <td><?=$params['paramType'][$i]?></td>
                            <td><?=$params['default'][$i]?></td>
                            <td><?=$params['des'][$i]?></td>
                        </tr>
                <?php
                        }
                    }
                ?>
              </tbody>    
            </table>
        </div>
    </div>

    <div class="col-xs-12 padding-5" style="margin:50px 0 0 0;background-color: #d9edf7;border-color:#bce8f1;color:#31708f">
        <div class="col-xs-12"><h4>返回结果</h4></div>
        <div class="col-xs-12" style="color:#3170AE">
        </div>
        <div class="col-xs-12">
            <pre><?=$model->returnResult?></pre>
        </div>
    </div>

    <div class="col-xs-12 padding-5" style="margin:50px 0 0 0;background-color: #d9edf7;border-color:#bce8f1;color:#31708f">
        <div class="col-xs-12"><h4>接口备注</h4></div>
        <div class="col-xs-12" style="color:#3170AE">
        </div>
        <div class="col-xs-12">
            <pre><?=$model->remark?></pre>
        </div>
    </div>
    <div>

</div>
